<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="jp.ac.segakuen.SelectListTable" %>
<%@ page import="jp.ac.segakuen.SelectListTableUtils" %>
<%@ page import="jp.ac.segakuen.OpenCampassMenuTable" %>
<%@ page import="jp.ac.segakuen.PMF" %>


<html>
<body>

<%
	PersistenceManager pm = PMF.get().getPersistenceManager();
	String query = "";
	String id = request.getParameter("id");
	String datestring = "";
 %>

	<H2>[オープンキャンパス指定日の実施項目]<p>
	指定日：
<%
	String query2="";
	query2="select from jp.ac.segakuen.SelectListTable where id == " + id;
	Query qr2 = pm.newQuery(query2);
	List<SelectListTable> slt = (List<SelectListTable>) qr2.execute();
	for (SelectListTable sltc : slt){
		out.print(sltc.getListText());
		datestring = sltc.getListText();
	}
%>
	<p>登録されている選択情報</H2><p>
<%
	if (id == null) {
  		query = "select from jp.ac.segakuen.OpenCampassMenuTable";
	}else{
		query = "select from jp.ac.segakuen.OpenCampassMenuTable where ocDateId == " + id;
 	}
	Query qr = pm.newQuery(query);
	List<OpenCampassMenuTable> ocmt = (List<OpenCampassMenuTable>) qr.execute();
    if (ocmt.isEmpty()) {
%>
		<p>登録されているデータはありません</p>
<%
	}else{
%>
		<table border=4>
		<TR>
		<TH>ID</TH><TH>内容1</TH><th>contents2</th><th>内容編集</th>
		</TR>
<%
       for (OpenCampassMenuTable ocm : ocmt) {
%>
			<TR>
			<td><%=ocm.getStringId()%></td>
			<td><%=ocm.getStringOcDateID()%></td> 
			<td><%=ocm.getStringOcMenuID()%></td>
			<td><form action="/opencampassmenutableservlet" method="post">
			<input type ="hidden" name="omid" value=<%=ocm.getStringId()%>>
			<input type ="hidden" name="id" value=<%=id%>>
			<input type="submit" name="submit" value="内容削除"></form></td>
			</TR>

<%
		}
%>
		</table>
<%		
	}
%>
	<h2><%=datestring%>に追加するコース:</h2>

<form action="/opencampassmenutableservlet" method="post">
<input type ="hidden" name="id" value="<%=id%>">
<select name="cource" id="cource" />
<option selected>--選択してください----------------</option>

<%
	query = "select from jp.ac.segakuen.SelectListTable where displayPlaceHolder == 'occourse' order by sortOrder ASC";
	List<SelectListTable> selectlist = (List<SelectListTable>) pm.newQuery(query).execute();
    if (selectlist.isEmpty()) {
      	 	out.println("<option>----------</option>");   
    }else{
		for (SelectListTable l : selectlist) {
     		out.println("<option>" + l.getListText() + "</option>");
     	}
	}
%>
</select>
<%        
    pm.close();
%>
<input type="submit" name="submit" value="項目追加">
</p>
</form>
</body>
</html>
